package com.jyw.business.de.controller;

import com.jyw.business.de.domain.dto.web.DemandAllocationConfigDto;
import com.jyw.business.de.domain.vo.web.DemandAllocationConfig;
import com.jyw.business.de.service.ISysDemandAllocationConfigService;
import com.jyw.common.annotation.Log;
import com.jyw.common.core.domain.CommonResult;
import com.jyw.common.core.domain.model.SimpleDto;
import com.jyw.common.enums.BusinessType;
import com.jyw.system.domain.vo.SysDemandReminderConfigVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author Created by ZhangCheng on 2023/08/16 (系统工单提醒配置)
 */
@Api(tags = "系统需求分配配置")
@RestController
@RequestMapping("/system/demand/allocation/config")
public class SysDemandAllocationConfigController {

    @Resource
    private ISysDemandAllocationConfigService demandAllocationConfigService;

    /**
     * 获取系统工单提醒配置
     *
     * @return
     */
    @GetMapping("/getConfig")
    @ApiOperation("获取系统需求分配配置")
    public CommonResult<DemandAllocationConfig> getConfig() {
        return CommonResult.success(demandAllocationConfigService.getConfig());
    }

    /**
     * 获取系统工单提醒配置
     *
     * @return
     */
    @PutMapping("/set/open")
    @ApiOperation("设置需求负责人分配开关")
    public CommonResult setOpen(@RequestBody SimpleDto<Boolean> dto) {
        demandAllocationConfigService.setOpen(dto);
        return CommonResult.success();
    }

    /**
     * 获取系统工单提醒配置
     *
     * @return
     */
    @PutMapping("/set/allocation")
    @ApiOperation("设置需求分配人")
    public CommonResult setAllocation(@RequestBody @Valid DemandAllocationConfigDto dto) {
        demandAllocationConfigService.setAllocation(dto);
        return CommonResult.success();
    }

}
